package com.ruoyi.house_sale.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.house_sale.domain.PaidSort;
import com.ruoyi.house_sale.service.IPaidSortService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收付款类别Controller
 * 
 * @author ruoyi
 * @date 2022-03-30
 */
@RestController
@RequestMapping("/house_sale/PaidSort")
public class PaidSortController extends BaseController
{
    @Autowired
    private IPaidSortService paidSortService;

    /**
     * 查询收付款类别列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidSort:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaidSort paidSort)
    {
        startPage();
        List<PaidSort> list = paidSortService.selectPaidSortList(paidSort);
        return getDataTable(list);
    }

    /**
     * 获取收付款类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidSort:query')")
    @GetMapping(value = "/{paidsortid}")
    public AjaxResult getInfo(@PathVariable("paidsortid") Long paidsortid)
    {
        return AjaxResult.success(paidSortService.selectPaidSortByPaidsortid(paidsortid));
    }

    /**
     * 新增收付款类别
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidSort:add')")
    @Log(title = "收付款类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaidSort paidSort)
    {
        return toAjax(paidSortService.insertPaidSort(paidSort));
    }

    /**
     * 修改收付款类别
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidSort:edit')")
    @Log(title = "收付款类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaidSort paidSort)
    {
        return toAjax(paidSortService.updatePaidSort(paidSort));
    }

    /**
     * 删除收付款类别
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidSort:remove')")
    @Log(title = "收付款类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paidsortids}")
    public AjaxResult remove(@PathVariable Long[] paidsortids)
    {
        return toAjax(paidSortService.deletePaidSortByPaidsortids(paidsortids));
    }
}
